public class Test{
    public static int[] findSecondLargest(int[] arr){
        int m;
        int s;
        if(arr[0]>arr[1]){
            m=arr[0];
            s=arr[1];
        }else{
            m=arr[1];
            s=arr[0];
        }
        for(int i=2;i<arr.length;i++){
            if(arr[i]>s){
                s=arr[i];
                if(s>m){
                int t=m;
                    m=s;
                    s=t;
                }
            }
        }
        int[] arr1=new int[]{m,s};
        return arr1;
        }

    

    public static void main(String[] args){
        int[] arr={1,56,7,34,8,9};
        int[] secondLargest= findSecondLargest(arr);
        System.out.println("次大值是: "+secondLargest[1]);
        System.out.println("最大值是: "+secondLargest[0]);
        }
}
